home *** CD-ROM | disk | FTP | other *** search
- {
- FROM: Arnim Noeldechen, 100016,2771
- TO: gayle davis, 72067,2726
- DATE: 12/21/94 1:08 PM
- {
- Hello gayle,
-
- thank you for giving us the great SWAG library. Its always a source
- of inspiration to me.
-
- I send you a contribution which was inspired by the drives2.pas
- snippet.
-
- SearchAllDrives looks for a file on all available Drives local
- and remote. It screens out Drives with identical VolumeId. It
- can handle netware-drives - mapped to different directories -
- because of the identical volumeid.
-
- bye
- Arnim Noeldechen
- 100016,2771@compuserve.com
- -------------------------------
- {TURBO 6.0}
- {$A+,B-,D+,E+,F+,G-,I+,L+,N-,O+,R+,S+,V-,X+}
- {$M 16384,0,655360}
- program SearchAllDrives;
-
- uses dos, crt;
-
- type
- charset = set of char;
- var sDrv,
- s : string;
- i,
- bDrives : byte;
- fFound : boolean;
-
- function upCaseSt ( s : string ) : string;
- var i : byte;
- begin
- for i := 1 to Length(s) do
- s[i] := UpCase(s[i]);
- upCaseSt := s;
- end;
-
- function AddBackSlash ( path : string ) : string;
- begin
- AddBackSlash := path;
- if path [length(path)]<>'\' then
- AddBackSlash := path+'\';
- end;
-
- function WordCount ( s : string; Sep : charset) : byte;
- var i, cnt : byte;
- begin
- cnt := 0;
- for i := 1 to length (s) do begin
- if s [i] in Sep then inc (cnt);
- end;
- WordCount := cnt;
- end;
-
- function GetWord ( n : byte; s : string; Sep : charset) : string;
- var
- I, Count, bLenW,
- bLenS : Byte;
- sWord : string;
- begin
- Count := 1; I := 1; bLenW := 0; bLenS := length (s);
- GetWord := ''; sWord := '';
-
- while (I <= bLenS) and (Count <= N) do begin
- if s[i] in Sep then begin
- inc (i);
- inc (Count);
- end;
- while (I <= bLenS) and not(S[I] in Sep) do begin
- if Count = N then begin
- Inc(bLenW);
- sword[0] := Char(bLenW);
- sword[bLenW] := S[I];
- end;
- Inc(I);
- end;
- end;
- GetWord := sWord;
- end;
-
- Procedure GetDriveList (var DriveList : string);
-
- Var
- Count : Integer;
- DirInfo : SearchRec;
- s : string;
- DrvLst : string;
-
- begin
- DriveList :='';
- s := ''; DrvLst := '';
- Writeln('You have Drives: ');
- For Count := 3 to 26 do
- if DiskSize(Count) > 0 then begin
- FINDfirst (chr(64+Count)+':\*.*',VolumeID,DirInfo);
- if pos(DIRINFO.Name,s)=0 then begin
- s := s+DIRINFO.NAME;
- Write (UpCase(Chr(ord('a') - 1 + Count)),': - ');
- writeln (DIRINFO.Name);
- DrvLst := DrvLst + UpCase(Chr(ord('a') - 1 + Count))+':'+';';
- end;
- end;
- WriteLn;
- DriveList := DrvLst;
- end;
-
- procedure _dirscan ( sdir : string; ind, Search : string);
- var dirinfo : SearchRec;
- begin
- if fFound then exit;
- findfirst (addBackSlash(sdir)+'*.*',AnyFile,DirInfo);
- while DosError = 0 do begin
- gotoXY(1,wherey);
- DelLine;
- write (ind,addBackSlash(sdir)+DirInfo.Name);
- if Dirinfo.name=search then begin
- fFound := true;
- exit;
- end;
- if ((DirInfo.Attr and Directory)=Directory) and
- (DirInfo.Name[1]<>'.') then begin
- _dirscan (addBackSlash(addBackSlash(sdir)+DirInfo.Name),Ind+' ',Search);
- if fFound then exit;
- end;
- FindNext(DirInfo);
- end;
- end;
-
- procedure dirscan ( sdir : string; ind, Search : string);
- begin
- _dirscan (sdir,ind, upcasest(Search));
- gotoXY(1,whereY);
- DelLine;
- if fFound then write('File '+Search+' found.')
- else write ('File '+Search+' not found.');
- end;
-
- begin
- fFound := false;
- GetDriveList (s);
- bDrives := WordCount (s,[';']);
- for i := 1 to bDrives do
- begin
- sDrv := addBackSlash(GetWord (i,s,[';']));
- writeln ('Checking Drive ',sDrv);
- dirscan (sDrv,'','NAME.EXT');
- writeln;
- end;
- end.
- -----------------------------------------------